from django import forms
from .models import MyUser


class RegisterForms(forms.ModelForm):
    # 自定义数据库中没有的字段
    password2 = forms.CharField(label="确认密码", widget=forms.PasswordInput(attrs={
        "id": "password2",
        "placeholder": "请再次输入密码",
        "class": "form-control"
    }))

    # 控制原始模型表单
    class Meta:
        # 根据的用户模型
        model=MyUser
        # 将要显示的字段
        fields = ["username", "password", "email", "telephone", "sex"]
        # 设置过i每个字段的属性
        widgets = {
            "username": forms.TextInput(attrs={
                "id": "username",
                "placeholder": "请输入用户名",
                "class": "form-control"
            }),
            "password": forms.PasswordInput(attrs={
                "id": "password",
                "placeholder": "请输入密码",
                "class": "form-control"
            }),
            "email": forms.EmailInput(attrs={
                "id": "email",
                "placeholder": "请输入邮箱",
                "class": "form-control"
            }),
            "telephone": forms.TextInput(attrs={
                "id": "telephone",
                "placeholder": "请输入手机号",
                "class": "form-control"
            }),
            "sex": forms.TextInput(attrs={
                "id": "username",
                "placeholder": "请输入性别",
                "class": "form-control"
            })

        }
